package com.ruoyi.web.controller.play;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.play.domain.PlayOperaLog;
import com.ruoyi.play.service.IPlayOperaLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 片单剪辑发布记录Controller
 *
 * @author ruoyi
 * @date 2025-11-20
 */
@RestController
@RequestMapping("/play/log")
public class PlayOperaLogController extends BaseController {
    @Autowired
    private IPlayOperaLogService playOperaLogService;

    /**
     * 查询片单剪辑发布记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PlayOperaLog playOperaLog) {
        startPage();
        List<PlayOperaLog> list = playOperaLogService.selectPlayOperaLogList(playOperaLog);
        return getDataTable(list);
    }

    /**
     * 导出片单剪辑发布记录列表
     */
    @Log(title = "片单剪辑发布记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlayOperaLog playOperaLog) {
        List<PlayOperaLog> list = playOperaLogService.selectPlayOperaLogList(playOperaLog);
        ExcelUtil<PlayOperaLog> util = new ExcelUtil<PlayOperaLog>(PlayOperaLog.class);
        util.exportExcel(response, list, "片单剪辑发布记录数据");
    }

    /**
     * 获取片单剪辑发布记录详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(playOperaLogService.selectPlayOperaLogById(id));
    }

    /**
     * 新增片单剪辑发布记录
     */
    @Log(title = "片单剪辑发布记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlayOperaLog playOperaLog) {
        return toAjax(playOperaLogService.insertPlayOperaLog(playOperaLog));
    }

    /**
     * 修改片单剪辑发布记录
     */
    @Log(title = "片单剪辑发布记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlayOperaLog playOperaLog) {
        return toAjax(playOperaLogService.updatePlayOperaLog(playOperaLog));
    }

    /**
     * 删除片单剪辑发布记录
     */
    @Log(title = "片单剪辑发布记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(playOperaLogService.deletePlayOperaLogByIds(ids));
    }
}
